package sk.fritz.megafonsms;

import java.io.InputStream;
import java.util.Hashtable;

import javax.microedition.lcdui.Item;

import sk.fritz.megafonsms.util.Util;

public class ItemLocalizer implements ItemModifier {
	
	private Hashtable localized;
	
	public ItemLocalizer(String lang) {
		InputStream in = this.getClass().getResourceAsStream(
				"/" + lang + ".properties");
		localized = Util.readProperties(in);
	}

	public Item modifyItem(Item item) {
		String label =item.getLabel();
		String localizedLabel = (String) localized.get(label);
		if (localizedLabel != null)
			item.setLabel(localizedLabel);
		else
			System.out.println("Missing localized string for " + label);
		return item;
	}

}
